<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c"%>
<%
	String path = request.getContextPath();
%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>客户中间人信息</title>
<jsp:include page="../../import.jsp" flush="true" />
</head>
<body>
		<form id="cust_cst_mid_man_info_form">
            <div class="fieldset1 tabel_col tabel_col_s clearFix noBorder">
                <div class="fieldBox col_50">
                    <div class="label">姓名</div>
                    <div class="field">
                        <input name="mNm" id="mNm" type="text" class="ui-textbox" value="" validate="{required:true,nmcharacter:true, maxlength:20}">
                        <span class="requiredSymbol">*</span>
                    </div>
                </div>
                <div class="fieldBox col_50">
                    <div class="label">手机号</div>
                    <div class="field">
                        <input name="mMp" id="mMp" type="text" class="ui-textbox" value="" validate="{required:true,mobile: true, maxlength:20}">
                        <span class="requiredSymbol">*</span>
                    </div>
                </div>
                <div class="fieldBox col_50">
                    <div class="label">身份证号</div>
                    <div class="field">
                        <input name="mIdNo" id="mIdNo" type="text" class="ui-textbox" value="" validate="{required:true, idcardno: true}">
                         <span class="requiredSymbol">*</span>
                    </div>
                </div>
                <div class="fieldBox col_100">
                    <div class="label">备注</div>
                    <div class="field">
                        <textarea name="mRem" id="mRem" rows="4" class="l-textarea" style="width:92%" validate="{maxlength:100}"></textarea>
                    </div>
                </div>
                <!-- hide data -->
		        <div class="fieldBox col_100" style="display:none;">
		          <div class="field">
		              <input name=cstId id="cstId" type="text" class="ui-textbox" value="${cstId}">
		              <input name="mId" id="mId" type="text" class="ui-textbox" value="${mId}">
		          </div>
		        </div>
            </div>
        </form>
	<script>
	
		$(function() {
			initData();
			initEvent();
	       /*  var item = $('input[name=isDeduct][checked]').val();
	       	var cb = document.getElementById("isDefDeductYes");
	        if(item==0){
	            cb.disabled = true;
	        } */
		});
		
		//初始化数据
		function initData(){
			initFormData();
			initForm();
    	}
		
		//初始化事件
		function initEvent(){
		}
		
		//初始化表单
		function initForm(){
			$("#cust_cst_mid_man_info_form").ligerForm({
           	 validate: true
       		});
		}
		
		//父级窗口回调
		frameElement.dialog.onOk = function () {
			save();
		}
		
		frameElement.dialog.onCancel = function () {
			frameElement.dialog.close();
		}

	
		//新增修改事件
		function save(){
			var ligerForm = liger.get("cust_cst_mid_man_info_form");
            if (!ligerForm.valid()) {
                $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO,SQ_type: "warning"});
                return false; //验证不通过，不执行以下代码
            }
            var data = ligerForm.getData();
            var mId = $("#mId").val();
            var url = '<%=path%>/customer/cstmidmaninfo/add.do';
            if(mId != ""){
            	url = '<%=path%>/customer/cstmidmaninfo/modify.do';
            	data["id"]= mId;
            }
            var wait_dialog= $.ligerDialog.SQalert({
	            content: LogUtils.LOG_CMM_LOADING,
	            SQ_type: "waitting",
	            onClose: function () {
	            }
	        });
            //设置客户ID
            var cstId = $("#cstId").val();
            data["cstId"]= cstId;
            $.ajax({
        		type: 'post',
        		dataType:'json',
        		data:data,
        		url: url,
        		success:function(msg){
        			wait_dialog.close();
        			 if(msg.success == 1){
        				 $.ligerDialog.SQalert({content: msg.info,SQ_type: "success"});
        				 parent.midManGrid.setParm("cstId",cstId);
        				 parent.midManGrid.reload();
        				 frameElement.dialog.close();
        			 }else{
        				 $.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
        			 }
        		}
        	});
		}
		
		//初始化FORM 数据
		function initFormData(){
			var mId = $("#mId").val();
	    	if(!mId)return;
	    	var wait_dialog= $.ligerDialog.SQalert({
	            content: LogUtils.LOG_CMM_LOADING,
	            SQ_type: "waitting",
	            onClose: function () {
	            }
	        });
	    	var _url = '<%=path%>/customer/cstmidmaninfo/getById.do';
	    	$.ajax({
	    		type: 'get',
	    		dataType:'json',
	    		data:{id:mId},
	    		url: _url,
	    		success:function(msg){
	    			wait_dialog.close();
	    			 if(msg.success == 1){
	    				 setData(msg.data);//设置数据
	    			 }else{
	    				 $.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
	    			 }
	    		}
	    	});
		}
		
		//设置页面数据
	    function setData(data){
	    	var form = new liger.get("cust_cst_mid_man_info_form");
	    	form.setData({
	    		mNm:data.mnm,
	    		mMp:data.mmp,
	    		mIdNo:data.midNo,
	    		mRem:data.mrem
	    	});
		};
		
	</script>

</body>
</html>